import fetch from 'utils/fetch';
/**
 * 卡券管理
 */
// 卡券服务列表接口
export function listCardServiceInfo(schoolId, page, rows) {
    const data = {
        schoolId,
        page,
        rows
    };
    return fetch({
        url: '/cardService/listCardServiceInfo',
        method: 'post',
        data
    });
}

// 卡券服务列表子列表接口
export function listCardNumsBySchoolType(schoolId) {
    const data = {

    };
    return fetch({
        url: '/cardService/listCardNumsBySchoolType/' + schoolId,
        method: 'post',
        data
    });
}

// listCardServiceDeatilInfo

// 卡券类型总数统计(总数,已使用,未使用,已作废,未发放)接口
export function getCardNumsBySchoolType(schoolId) {
    const data = {

    };
    return fetch({
        url: '/cardService/listCardNumsBySchoolType/' + schoolId,
        method: 'post',
        data
    });
}

// 卡券查看列表接口
export function listCardCouponsByOrgid(page, rows, serviceId, schoolId, cardCoupons, usingState) {
    const data = {
        page,
        rows,
        serviceId,
        schoolId,
        cardCoupons,
        usingState
    };
    return fetch({
        url: '/cardService/listCardCouponsByOrgid',
        method: 'post',
        data
    });
}

// 购买卡券接口
export function saveIncrementCardCoupons(
    sSchoolName, fSchoolId,
    fServiceId, sServiceName,
    sCardCouponsNum, sType, sOrderMoney,
    timestore, sCardMoney, sShouldPayMoney) {
    const data = {
        sSchoolName,
        fSchoolId,
        fServiceId,
        sServiceName,
        sCardCouponsNum,
        sType,
        sOrderMoney,
        timestore,
        sCardMoney,
        sShouldPayMoney
    };
    return fetch({
        url: '/cardService/saveIncrementCardCoupons',
        method: 'post',
        data
    });
}

// 学校名称接口
export function listSchoolAllInfo() {
    return fetch({
        url: '/serviceOrder/listSchoolAllInfo',
        method: 'post'
    });
}

// 班级接口
export function listClassInfoBySchoolId(schoolId) {
    const data = {

    };
    return fetch({
        url: '/serviceOrder/listClassInfoBySchoolId/' + schoolId,
        method: 'post',
        data
    });
}

// 卡券购买记录详情接口
export function getCouponPurchaseDetails(pId) {
    const data = {

    };
    return fetch({
        url: '/cardService/getCouponPurchaseDetails/' + pId,
        method: 'post',
        data
    });
}

// 卡券购买记录接口
export function listVoucherPurchaseRecord(fSchoolId, page, rows) {
    const data = {
        fSchoolId,
        page,
        rows
    };
    return fetch({
        url: '/cardService/listVoucherPurchaseRecord',
        method: 'post',
        data
    });
}
// 购买详情
export function getCouponPurchaseInfo(schoolId, serviceId) {
    const data = {

    };
    return fetch({
        url: '/cardService/getCouponPurchaseInfo/' + schoolId + '/' + serviceId,
        method: 'post',
        data
    });
}

// getCouponPurchaseInfo
// 卡券发放(包括批量发放，单发放操作时pId不能为空)接口
export function saveCardGrant(grantUserId, grantUserName, grantClassId, grantCalssName, schoolId, schoolName, serviceId, serviceName, orgUserId, orgUserName, pId, useFulLife) {
    const data = {
        grantUserId, // 家长id数组
        grantUserName, // 家长名字数组
        grantClassId, // 班级id数组
        grantCalssName, // 班级名字数组
        schoolId,
        schoolName,
        serviceId,
        serviceName,
        orgUserId,
        orgUserName,
        pId,
        useFulLife
    };
    return fetch({
        url: '/cardService/saveCardGrant',
        method: 'post',
        data
    });
}

// 卡券开通(通过批次号id)接口
export function openServiceByBatchNumberId(pId) {
    const data = {

    };
    return fetch({
        url: '/cardService/openServiceByBatchNumberId/' + pId,
        method: 'post',
        data
    });
}

// 卡券开通(卡券发放记录详情)接口
export function openServiceByCardId(cardId) {
    const data = {
        cardId // [ "2859809" , "2859813"]
    };
    return fetch({
        url: '/cardService/openServiceByCardId',
        method: 'post',
        data
    });
}

// 分页查询卡券发放列表
export function listCardCouponsGrantRecord(page, rows, schoolId, queryDate) {
    const data = {
        page,
        rows,
        schoolId,
        queryDate
    };
    return fetch({
        url: '/cardService/listCardCouponsGrantRecord',
        method: 'post',
        data
    });
}

// 卡券发放记录详情列表(查看按钮)
export function listCardCouponsGrantDetail(page, rows, phone, classId, usingUserid, batchNumberId) {
    const data = {
        page,
        rows,
        phone,
        classId,
        usingUserid,
        batchNumberId
    };
    return fetch({
        url: '/cardService/listCardCouponsGrantDetail',
        method: 'post',
        data
    });
}

// 卡券发放家长学生信息接口
export function listFamilyRelation(classId, parentPhone, studentName) {
    const data = {
        parentPhone,
        classId,
        studentName
    };
    return fetch({
        url: '/cardService/listFamilyRelation',
        method: 'post',
        data
    });
}

// 获取开通时长下拉信息
export function listOpenTimeData(schoolId,serviceId) {
    const data = {
        schoolId,
        serviceId
    };
    return fetch({
        url: '/cardService/listOpenTimeData',
        method: 'post',
        data
    });
}

// 选择开通时长获取卡券数量
export function getCardNotGrantNums(schoolId, serviceId, useFulLife) {
    const data = {
        schoolId,
        serviceId,
        useFulLife
    };
    return fetch({
        url: '/cardService/getCardNotGrantNums',
        method: 'post',
        data
    });
}
